import com.java.demo.model.User;
import org.springframework.beans.factory.BeanNameAware;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 马拉圈
 * Date: 2023-08-01
 * Time: 20:38
 */
public class BeanLife implements BeanNameAware {

    @Autowired
    private User user;

    @PostConstruct
    public void doPostConstruct() {
        user.setName("玛卡巴卡");
        System.out.println("执行了doPostConstruct");
    }
    @PreDestroy
    public void doPreDestroy() {
        System.out.println("执行了doPreDestroy");
    }

    public void init() {
        System.out.println("执行了init");
    }
    public void destroy() {
        System.out.println("执行了destroy");
    }
    @Override
    public void setBeanName(String s) {
        System.out.println("执行了BeanNameAware -> " + s);
    }
    public void sayHi() {
        System.out.println("Hi, BeanLife");
    }
}
